import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import { registerMicroApps, start,initGlobalState } from 'qiankun';

Vue.config.productionTip = false

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')

registerMicroApps([
    {
        name: 'child',
        entry: '//localhost:9000',
        container: '#container',
        activeRule: '/sub',
    }
]);
// 启动 qiankun
start(
    {
        excludeAssetFilter: (urls) => {
            const whiteList = []
            const whiteWords = ['baidu'] // 异步加载百度地图白名单
            if (whiteList.includes(urls)) return true
            return whiteWords.some(w => urls.includes(w))
        }
    }
);
const state = {
    baiduinit: window,
    abc: 456
}
const actions = initGlobalState(state);
actions.onGlobalStateChange((state, prev) => {
    // state: 变更后的状态; prev 变更前的状态
    console.log(state, prev);
});
